package com.cskaoyan.shopping;

import com.cskaoyan.shopping.dal.persistence.PanelContentMapper;
import com.cskaoyan.shopping.dal.persistence.PanelMapper;
import com.cskaoyan.shopping.dto.*;
import com.cskaoyan.shopping.service.impl.IProductPanelGoodsServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @author FuHao
 * @version 1.0.0
 * @description TODO
 * @date 2022/6/18 14:26
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class ShoppingHomepage {

    @Autowired
    PanelMapper panelMapper;

    @Autowired
    IProductPanelGoodsServiceImpl iProductPanelGoodsService;

    @Autowired
    PanelContentMapper panelContentMapper;


    @Test
    public void testHomepage() {

        // List<PanelDto> panel = iProductPanelGoodsService.IProductPanelHomepage();

        List<PanelDto> panel = panelMapper.selectPanelContentById();

        for (PanelDto panelDto : panel) {
            Integer panelId = panelDto.getId();
            List<PanelContentItemDto> panelDtos = panelContentMapper.selectPanelContentAndProductWithPanelId(panelId);

            panelDto.setPanelContentItems(panelDtos);
        }
        PanelDtoResponse panelDtoResponse = new PanelDtoResponse();
        panelDtoResponse.setPanelDtoList(panel);

        System.out.println(panelDtoResponse);


        // List<PanelContentDto> navigationList = panelContentMapper.queryPanelContentNavigation();
        //
        // NavListResponse navListResponse = new NavListResponse();
        // navListResponse.setPannelContentDtos(navigationList);
        //
        // System.out.println(navListResponse);

        // List<ProductCateDto> productCateDtos = panelMapper.queryProductCategories();
        // System.out.println(productCateDtos);


    }


}
